package org.reference.generic.operator;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

import org.reference.generic.base.Parameter;
import org.reference.generic.information.Gene;
import org.reference.generic.operator.Node;

/**
 * 
 */
public abstract class Function extends Node {

    /**
     * 
     */
    public Function(Parameter parameters) {
    	super(parameters);
    }

    public void operation() {
		List<Double> results = new ArrayList<Double>();
		for (Node node : branches) {
			if (!node.isTerminal()){
				((Function) node).operation();
			}
				results.add(node.getResult());
		}
		
		calc(results);
		setResult(results.get(0));
    };
    
    public abstract void calc(List<Double> results);
}

